package cn.tedu.online.day01wan;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class StudentTest {
    public static void main(String[] args) {
        Student student = new Student(20,185,70);
        Student student1 = new Student(20,185,60);
        Student student2 = new Student(22,156,80);
        Student student3 = new Student(22,189,90);
        Student student4 = new Student(23,160,55);
        Student student5 = new Student(23,195,60);
        List<Student> list = new ArrayList<>();
        list.add(student);
        list.add(student1);
        list.add(student2);
        list.add(student3);
        list.add(student4);
        list.add(student5);

        Collections.sort(list, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                if (o1.getAge()!=o2.getAge()) {
                    return o1.getAge()-o2.getAge();
                }else if (o1.getHeight() == o2.getHeight()) {
                        return o1.getHeight().compareTo(o2.getHeight());
                    } else {
                    return o1.getWeight().compareTo(o2.getWeight());
                }


            }
        });

        for (Student s : list){
            System.out.println(s);
        }

    }
}
